import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const Layout = () => import("@/layout/index.vue");
const Home = () => import("@/views/home/index.vue");
const SubContainer = () => import("@/views/sub-container/index.vue");

export const routes = [
  {
    path: "/",
    component: Layout,
    children: [
      {
        path: "",
        name: "Home",
        component: Home,
        meta: {
          title: "首页",
          icon: "view",
        },
      },
    ],
  },
  {
    path: "/react",
    component: Layout,
    meta: {
      title: "React子应用",
      icon: "watch",
    },
    children: [
      {
        path: "",
        name: "React",
        component: SubContainer,
        meta: {
          title: "React首页",
        },
      },
      {
        path: "test",
        name: "ReactTest",
        component: SubContainer,
        meta: {
          title: "React测试",
        },
      },
    ],
  },
  {
    path: "/vue2",
    component: Layout,
    meta: {
      title: "Vue2子应用",
      icon: "watch",
    },
    children: [
      {
        path: "",
        name: "Vue2",
        component: SubContainer,
        meta: {
          title: "Vue2首页",
        },
      },
    ],
  },
  {
    path: "/vue3",
    component: Layout,
    meta: {
      title: "Vue3子应用",
      icon: "watch",
    },
    children: [
      {
        path: "",
        name: "Vue3",
        component: SubContainer,
        meta: {
          title: "Vue3首页",
        },
      },
    ],
  },
  {
    path: "*",
    redirect: "/",
    hidden: true,
  },
];

export default new VueRouter({
  mode: "history",
  routes,
  scrollBehavior() {
    return { x: 0, y: 0 };
  },
});
